PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Filter

The Filter reference form specifies all objects in a container that match one or more conditions specified in a Boolean expression. The Filter reference form specifies application objects only. It cannot be used to filter AppleScript objects: lists, records, or strings. For more information, see Using the Filter Reference Form.

SYNTAX
referenceToObject ( whose | where ) Boolean

where

referenceToObject is a reference that specifies one or more objects.

Boolean is any Boolean expression.

The words whose and where have the same meaning.

EXAMPLES

The following are some examples of references that use the Filter reference form. For additional examples, see Using the Filter Reference Form.

The following example specifies a list of file references for all files in the Control Panels folder with file type 'APPL' .

tell application "Finder"
    every file in control panels folder whose file type is "APPL"
end tell

The following example specifies all application windows that do not match a given name:

tell application "AppleWorks"
    every window whose name is not "Old Report (WP)"
end tell
NOTES

Except for the Every Element reference form, the application returns an error if no objects pass the test or tests. For the Every Element reference form, the application returns an empty list, {}, if no objects pass the test or tests.

To specify a container after a filter, you must enclose the filter and the reference it applies to in parentheses. For example, the parentheses around words 1 thru 5 whose first character = "M" in the following reference are required because the container of paragraph 5 follows the filter.

tell application "Finder"
    (files whose file type is "APPL") in control panels folder
end tell

© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)